import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/quarystring")
public class QuarystringParameterServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 此处约定, 请求中给定的 query string 是形如: username=zhangsan&password=123
        // 上述 query string, 就会被 tomcat 给自动解析成一个 Map 这样的结构.

        String name=req.getParameter("name");
        String password=req.getParameter("password");

        System.out.println("name=" + name);
        System.out.println("password=" + password);

        resp.setContentType("text/html;charset=utf8");
        resp.getWriter().write(name + " " + password + " : ok");

    }
}
